home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / examples / eval_demo < prev    next >
Text File  |  1994-07-13  |  545b  |  45 lines

  1. //
  2. // The beginning of an eval() demonstration
  3. //
  4.  
  5. //
  6. // First define two functions for evaluating string matrices.
  7. //
  8.  
  9. evalm = function ( M )
  10. {
  11.   local (m, i)
  12.  
  13.   if (class (M) != "string") 
  14.   {
  15.     error ("evalm: argument must be class string");
  16.   }
  17.  
  18.   for (i in 1:M.n)
  19.   {
  20.     m[i] = eval (M[i]);
  21.   }
  22.  
  23.   return m;
  24. };
  25.  
  26. eval2m = function ( M )
  27. {
  28.   local (m)
  29.  
  30.   // The first time
  31.   m = evalm (M);
  32.  
  33.   //
  34.   // Now do it again if the result
  35.   // is all string
  36.   //
  37.  
  38.   if (class (m) != "string")
  39.   {
  40.     return m;
  41.   else
  42.     return evalm (m);
  43.   }
  44. };
  45.